package com.ruoyi.experiment.utils;

public class Num {
    public static int get(Integer num,Integer i){
        StringBuilder stringBuilder = new StringBuilder("" + num);
        String n=stringBuilder.reverse().toString();
        if (n.length()<i){
            return 0;
        }
        return n.charAt(i-1)-'0';
    }
    public static int set(Integer num,Integer i,Integer n){
        String t=""+num;
        if (t.length()<i){
            StringBuilder sb=new StringBuilder(""+n);
            for (int j = 0; j < i - t.length()-1; j++) {
                sb.append("0");
            }
            sb.append(t);
            return Integer.parseInt(sb.toString());
        }
        return Integer.parseInt(t.substring(0,t.length()-i)+n+t.substring(t.length()-i+1));
    }
}
